/**
 * 
 */
package com.ms.game.common.container;

import java.math.BigDecimal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.xpec.c4.game.common.Helper;

/**
 * @author TW15010
 *
 */
public class BasicSettingServerBinUtil extends BasicBinUtil {
	
	/**
	 * 包月每日
	 */
	public static final String MONTHLY_DAILY_AWARD_FLUSH_TIME_FORMAT = "monthly_daily_award";
	/**
	 * 包週每日
	 */
	public static final String WEEKLY_DAILY_AWARD_FLUSH_TIME_FORMAT = "weekly_daily_award";
	/**
	 * 抽佣刷新
	 */
	public static final String DAILY_FLUSH_REBATE_TABLE_TIME_FORMAT = "commison";
	/**
	 * 抽佣保存天數
	 */
	public static final String COMMISON_KEEP_DAYS = "commison";
	
	/**
	 * 首轉每日登入獎勵 
	 */
	public static final String  FIREST_STORE_REWARD_FLUSH_TIME = "first_store_reward";
	
	
	public static BasicSettingServerBin bin = null;

	/** log4j object */
	private static final Log log = LogFactory.getLog(BasicSettingServerBinUtil.class);

	@Override
	public void onBinLoad(Object binInstance) {
		bin = (BasicSettingServerBin) binInstance;

		int triggerValue = bin.getMachineResetTriggerValue();
		if (triggerValue <= 0) {
			if (log.isErrorEnabled()) {
				log.error("MachineResetTriggerValue must > 0.");
			}
		}
	}

	/**
	 * 機台重置觸發金額門檻<br>
	 * 已經乘上單位值換算成實際值
	 * 
	 * @return
	 */
	public static BigDecimal getMachineResetTriggerValue() {
		BigDecimal triggerValue = new BigDecimal(bin.getMachineResetTriggerValue());
		BigDecimal realTriggerValue = Helper.mul(triggerValue, new BigDecimal(10000));

		return realTriggerValue;
	}
	
	/**
	 * 取得bin黨內event時間格式
	 */
	public static String getEventFlsuhTime(String eventName){
		return bin.getEventFlsuhTime().get(eventName);
	}
	
	/**
	 * 取得bin黨內event保存時間
	 */
	public static Integer getEventKeepDays(String eventName){
		return bin.getEventKeepDays().get(eventName);
	}
	
	/**
	 * 讀取菜鳥等級
	 * @return
	 */
	public static int getRookieLV()
	{
		return bin.getRookieForceLv();
	}
}
